package com.api.shopapi.mapper;

import com.api.shopapi.entity.MedicationItem;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface MedicationItemMapper {

    @Insert("insert into medication_item " +
            "(MedicationItemCode,MedicationGroupCode,Name) " +
            "values (#{medicationItem.MedicationItemCode} ,#{medicationItem.MedicationGroupCode} ," +
            "#{medicationItem.Name} )")
    int insert(@Param("medicationItem") MedicationItem medicationItem);

    @Update("update medication_item set MedicationGroupCode=#{medicationItem.MedicationGroupCode},Name=#{medicationItem.Name} " +
            "where MedicationItemCode=#{medicationItem.MedicationItemCode} ")
    int updateByMedicationItemCode(@Param("medicationItem") MedicationItem medicationItem);

    @Delete("delete from medication_item where MedicationGroupCode=#{medicationGroupCode}")
    int delByMedicationGroupCode(@Param("medicationGroupCode") String medicationGroupCode);

    @Select("select * from medication_item where MedicationGroupCode=#{medicationGroupCode} ")
    List<MedicationItem> getByMedicationGroupCode(@Param("medicationGroupCode") String medicationGroupCode);
}
